home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 2.1 KB | 54 lines | [TEXT/GEOL] |
- Item 4161816 11-Jan-90 09:52
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: FALK2 Austria - Alexander Falk
- MACAPP.TECH$ MacApp Technical
-
- Sub: RE>Instantiation “by clas
-
- Attn: Austria - Alexander Falk
- Attn: MacApp Tech
- SentBy: Larry Rosenstein
- Date 1/11/90
- Subject RE>Instantiation “by classn
- From Larry Rosenstein
- To Austria - Alexander Falk
- MacApp Tech
-
- Reply to: RE>Instantiation “by classname
- In MacApp 2.0b9, there's a way to instantiate any object given its class name.
- This is using the function NewObjectByClassName.
-
- The RegisterStdType procedure is used to give a type name a 4-character alias.
- You can then instantiate an object given its alias (or signature) with a call
- to NewStdObject.
-
- There are 2 reasons for doing this. One is that it saves space in the view
- resource. Instead of using the full class name, you can use just the
- 4-character signature.
-
- Second, it adds another level of indirection in view creation. If all
- instances of TWindow (for example) are created by based on its 4-character
- signature ('wind') then one can easily substitute a different window class by
- registering a different type with the same signature.
-
- This provides a limited way to customize MacApp without changing its source
- code. Suppose you modified TTEView to have a new capability. You can then
- register your subclass with the same signature as TTEView, then any view
- resource that refers to TTEView by signature will get your modified class
- instead.
-
- The part about inhibiting dead code stripping is a kludge, and one usually
- gets bitten by it the first time you instantiate a custom class by name (after
- the linker has stripped the class). It is desirable for the linker to strip
- classes that aren't created. It is impossible (in general) for the linker to
- know if a class is instantiated by name. Therefore, you have to explicitly
- tell it. A better solution, however, you be a linker option that listed the
- class names used in the program.
-
- Larry Rosenstein
-
-
-
-